#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <stdlib.h>

inline bool goNext(int *l1, int *l2, int len)
{
    for(int i = 0; i < len; i++)
    {
        l2[(i+1)%len]=(l1[i%len]>>1)+(l1[(i+1)%len]>>1);
        if(l2[(i+1)%len]%2==1)
            l2[(i+1)%len]+=1;
    }
    for(int i = 1; i < len; i++)
    {
        if(l2[i]!=l2[0])
            return false;
    }
    return true;

}
int main()
{
    int *l1,*l2;
    int n;
    while (1) {
        scanf("%d",&n);
        if(n==0)
            break;
        l1 = new int[n];
        l2 = new int[n];
        for(int i = 0; i < n; i++)
        {
            scanf("%d", &l1[i]);
        }
        int count = 0;
        bool same=true;
        for(int i = 1; i < n; i++)
        {
            if(l1[i]!=l1[0])
            {
                same=false;
            }
        }
        if(same)
            std::cout<<l1[0]<<" "<<0<<std::endl;
        else{
            while (!goNext(l1, l2, n)) {
                count++;
                int *t=l2;
                l2=l1;
                l1=t;
            }
            std::cout<<count+1<<" "<<l2[0]<<std::endl;
        }
        delete []l1;
        delete []l2;


    }
    return 0;
}
